﻿<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3c.org/TR/1999/REC-html401-19991224/loose.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta content="text/html; charset=UTF-8" http-equiv="Content-Type" />
    <title></title>
    <link href="/Contents/css/datagridtop.css" rel="stylesheet" type="text/css" />
    <script src="/Contents/scripts/jquery-1.8.0.min.js"type="text/javascript"></script>
    <script src="/Contents/scripts/jquery-easyui-1.3.2/jquery.easyui.min.js"type="text/javascript"></script>
    <link href="/Contents/scripts/jquery-easyui-1.3.2/themes/default/easyui.css"rel="stylesheet" type="text/css" />
    <link href="/Contents/scripts/jquery-easyui-1.3.2/themes/icon.css" rel="stylesheet"type="text/css" />
    <script src="/Contents/scripts/jquery-easyui-1.3.2/locale/easyui-lang-zh_CN.js" type="text/javascript"></script>
    <script src="/Contents/scripts/shadeform/script/form.js" type="text/javascript"></script>
    <link href="/Contents/scripts/shadeform/style/formsytle.css" rel="stylesheet"type="text/css" />
    <link href="/Contents/css/common.css" rel="stylesheet" type="text/css" />
    <script src="/Contents/scripts/functions.js" type="text/javascript"></script>
    <script src="/Contents/scripts/manager-js/admin-manager.js" type="text/javascript"></script>
</head>
<body style="background: none; padding-left: 15px; padding-right: 15px; padding-top: 2px;
    text-align: center;">
    <div class="GridTablesTop" id="biaotouwidth" style="width: 100%; padding-bottom: 10px;">
        <span class="spl">
            <strong><span>会计基础题库管理</span></strong>
        </span>
    </div>
    <table id="dg" ></table>
    <script type="text/javascript">
        // 设置工具条
        var toolbar = [{
            text: '添加管理员',
            iconCls: 'icon-add',
            handler: function () { showAddForm(); }
        }, '-', {
            text: '搜索管理员',
            iconCls: 'icon-search',
            handler: function () { showSearchForm(); }
        }];

        $(function () {
            $('#dg').datagrid({
                width: parseFloat(document.getElementById("biaotouwidth").clientWidth),
                striped: true,
                loading: true,
                loadMsg: "正在加载数据,请稍等...",
                idField: 'id',
                height: 440,
                singleSelect: true,
                toolbar: toolbar,
                autoRowHeight: false,
                url: '/AdminsManagement/GetAdminsJson?t=' + Math.random(),
                columns: [[
                    { field: 'name', title: '姓名', width: ($(document.body).width() - 250) * 0.15, align: 'center' },
                    { field: 'phone', title: '电话', width: ($(document.body).width() - 250) * 0.2, align: 'center' },
                    { field: 'account', title: '账号', width: ($(document.body).width() - 250) * 0.2, align: 'center' },
                    { field: 'level', title: '级别', width: ($(document.body).width() - 250) * 0.15, align: 'center',
                        formatter: function (value, rowData) {
                            var s;
                            if (value == "0") s = "管理员";
                            if (value == "1") s = "超级管理员";
                            if (value == "2") s = "系统管理员";
                            return s;
                        }
                    },
                    { field: 'add_time', title: '添加时间', width: ($(document.body).width() - 280) * 0.25, align: 'center' },
                    {
                        field: 'operation', title: '操作', width: 270, align: 'center',
                        formatter: function (value, rowData) {
                            var s = '<img src="/contents/images/admin/delete.png" align="middle""/>&nbsp;<a href="#" onclick="deleteAdmin(\'' + rowData.id + '\')" title="删除" style="color:blue;margin-left:5px; margin-right:5px;">删除</a>';
                            s += '&nbsp;|&nbsp;&nbsp;&nbsp;<img src="/contents/images/admin/pencil.png" align="middle"/>&nbsp;<a href="#" onclick="showUpdateForm(\'' + rowData.id + '\')" title="修改" style="color:blue;margin-left:5px; margin-right:5px;">修改</a>';
                            s += '&nbsp;|&nbsp;&nbsp;&nbsp;<img src="/contents/images/admin/resetpsword.png" align="middle"/>&nbsp;<a href="#" onclick="resetAdmin(\'' + rowData.id + '\')" title="将密码重置为电话号码" style="color:blue;margin-left:5px; margin-right:5px;">密码重置</a>';
                            return s;
                        }
                    }
	            ]],
                rowStyler: function (index, row) {
                    return 'height:35px;';
                },
                rownumbers: true, //行号    
                singleSelect: true, //是否单选
                pagination: true, //分页控件   
                onLoadSuccess: function (data) {
                    if (data.rows.length == 0) {
                        var body = $(this).data().datagrid.dc.body2;
                        body.find('table tbody').html('<tr><td colspan="6" width="' + body.width() + '" style="height: 25px; text-align: center;">没有数据</td></tr>');
                    }
                }
            });

            // 设置分页控件       
            var p = $('#dg').datagrid('getPager');
            $(p).pagination({
                pageSize: 10, //每页显示的记录条数，默认为10           
                pageList: [10, 20, 50], //可以设置每页记录条数的列表           
                beforePageText: '第', //页数文本框前显示的汉字           
                afterPageText: '页    共 {pages} 页',
                displayMsg: '当前显示 {from} - {to} 条记录   共 {total} 条记录'
            });

            // 当窗口大小发生变化时，调整DataGrid的大小  
            $(window).resize(function () {
                $('#dg').datagrid('resize', {
                    width: $(document.body).width()
                });
            });
        });

        function showAddForm() {
            var addForm = {
                title: "添加",
                width: 270,
                height: 300,
                templete: "<form action='' method='get' class='formClass'>" +
                            "<table width='100%'>" +
                            "<tr>" +
                            "<td align='left' valign='top'><iframe src='/AdminsManagement/AddAdminView' width='260' height='250'  marginwidth='0' marginheight='0' frameborder='0' allowtransparency='true'></iframe></td>" +
	                        "</tr>" +
                            "</table>" +
                            "</form>"
            }
            Shade.show(addForm);
        }

        function showSearchForm() {
            var searchForm = {
                title: "查询",
                width: 270,
                height: 240,
                templete: "<form action='' method='get' class='formClass'>" +
                            "<table width='100%'>" +
                            "<tr>" +
                            "<td align='left' valign='top'><iframe src='/AdminsManagement/QueryAdminView' width='260' height='190'  marginwidth='0' marginheight='0' frameborder='0' allowtransparency='true'></iframe></td>" +
	                        "</tr>" +
                            "</table>" +
                            "</form>"
            }
            Shade.show(searchForm);
        }

        function showUpdateForm(id) {
            var updateForm = {
                title: "修改",
                width: 270,
                height: 240,
                templete: "<form action='' method='get' class='formClass'>" +
                            "<table width='100%'>" +
                            "<tr>" +
                            "<td align='left' valign='top'><iframe src='/AdminsManagement/UpdateAdminInFrameView?id=" + id.toString() + "&t=" + Math.random() + "'width='260' height='190'  marginwidth='0' marginheight='0' frameborder='0' allowtransparency='true'></iframe></td>" +
	                        "</tr>" +
                            "</table>" +
                            "</form>"
            }
            Shade.show(updateForm);
        }

        function closeShade() {
            Shade.hidden();
        }

        // 添加 、 修改 、删除时刷新列表
        function reloadDG() {
            Shade.hidden();

            $('#dg').datagrid({
                url: '/AdminsManagement/GetAdminsJson?t=' + Math.random()
            });
        }

        // 查找时将搜索结果显示出来
        function reloadDGWithSearch(name, phone, account, level) {
            Shade.hidden();

            $('#dg').datagrid({
                url: '/AdminsManagement/QueryAdmin?name=' + encodeURI(name) + '&phone=' + encodeURI(phone) + '&account=' + encodeURI(account) + '&level=' + level + '&t=' + Math.random()
            });
        }       
    </script>
</body>
</html>
